package com.app.activitys;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.apache.http.util.ByteArrayBuffer;

import com.app.activitys.adapters.AdapterBar;
import com.app.entidades.Album;
import com.app.entidades.Bar;
import com.example.applucianokikao.R;
import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore.Images.Media;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.AdapterView.OnItemClickListener;

public class ActivityBares extends Activity implements OnItemClickListener{
	
	private ListView lista;
	private List<Bar> listaBares;
	private AdapterBar adapterBar;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_bares);
	
		Bundle extras = getIntent().getExtras();
		Bundle valor = extras.getBundle("bar");
		listaBares = (List<Bar>) valor.getSerializable("bares");
		
		adapterBar = new AdapterBar(this, 0, listaBares);
		adapterBar.setNotifyOnChange(true);
		
		lista = (ListView) findViewById(R.id.listaBares);
		lista.setAdapter(adapterBar);
		lista.setOnItemClickListener((OnItemClickListener)this);
		lista.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
		
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		Bar bar = listaBares.get(arg2);
		Intent intent = new Intent(ActivityBares.this, ActivityDetalhesBar.class);
		Bundle bundle = new Bundle();
		bundle.putSerializable("bar_objeto", (Serializable)bar);
		intent.putExtra("bar_bundle", bundle);	
		startActivity(intent);
	}
	
}
